package cron

import (
	"fly_export/global"
	"log"

	"github.com/robfig/cron/v3"
)

func RunCron() {
	c := cron.New()
	//var alerts []databases.Alert
	//global.GVA_MYSQL.Find(&alerts)
	c.AddFunc("*/1 * * * * ", func() {

		for _, v := range global.GVA_CONFIG.Alerts {
			log.Println("开始请求url：", v.Url)
			v.Run()
		}
		for _, vt := range global.GVA_CONFIG.Times {
			log.Println("开始请求url：", vt.Url)
			vt.Run()
		}
	})

	c.Start()
}
